﻿Imports System.Data
Imports System.Data.SqlClient 'SQL需要
Public Class SQL
    Dim SS As SqlConnection
    Dim Ds As DataSet = New DataSet
    Public Sub New(ByVal ID As String, ByVal Pwd As String, ByVal Address As String)
        SS = New SqlConnection("User ID=" + ID + ";Password=" + Pwd + ";Initial Catalog=RestaurantManagement;Data Source=" + Address) '连接数据库
    End Sub
    Public Function Sqlcmd(ByVal sSQL As String) As DataSet '数据库连接函数返回table
        Dim objCmd As New SqlCommand(sSQL, SS)
        Dim Da As SqlDataAdapter = New SqlDataAdapter(objCmd)
        'Dim Ds As DataSet = New DataSet
        Da.Fill(Ds)
        Return Ds
    End Function
    Public Function Sqlcmd(ByVal sSQL As String, ByVal name As String) As DataSet '数据库连接函数返回table,name为DataSet中表的名字
        Dim objCmd As New SqlCommand(sSQL, SS)
        Dim Da As SqlDataAdapter = New SqlDataAdapter(objCmd)
        Da.Fill(Ds, name)
        Return Ds
    End Function
End Class
